﻿#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <string>
#include <algorithm>
#include <unordered_set>
using namespace std;

//Day23
//1.打怪
int t;
int h, a, H, A;
int fun()
{
    if (a >= H) return -1;//攻击力大于毛球怪的血量，秒杀
    int m = (H / a) + (H % a != 0 ? 1 : 0);//怪物能抗几次
    int n = m - 1;//玩家能抗几次
    int x = n * A;//杀死一只怪物的时候，玩家掉多少血
    int ret = h / x - (h % x == 0 ? 1 : 0);
    return ret;
}
int main()
{
    cin >> t;
    while (t--)
    {
        cin >> h >> a >> H >> A;
        cout << fun() << endl;
    }
    return 0;
}

//2.字符串的分类
int n;
string s;
int main()
{
    cin >> n;
    unordered_set<string> hash;
    while (n--)
    {
        cin >> s;
        sort(s.begin(), s.end());
        hash.insert(s);
    }
    cout << hash.size() << endl;
    return 0;
}


//3.城市群数量
class Solution {
public:
    /**
     * 代码中的类名、方法名、参数名已经指定，请勿修改，直接返回方法规定的值即可
     *
     *
     * @param m int整型vector<vector<>>
     * @return int整型
     */
    bool vis[210] = { 0 };
    int citys(vector<vector<int> >& m)
    {
        int n = m.size();
        int ret = 0;
        for (int i = 0; i < n; i++)
        {
            if (!vis[i])
            {
                ret++;
                dfs(m, i);
            }
        }
        return ret;
    }
    void dfs(vector<vector<int>>& m, int pos)
    {
        vis[pos] = true;
        for (int i = 0; i < m.size(); i++)
        {
            if (!vis[i] && m[pos][i])
            {
                dfs(m, i);
            }
        }
    }
};

//Day24
//1.判断是不是平衡二叉树
struct TreeNode {
    *int val;
    *struct TreeNode* left;
    *struct TreeNode* right;
    *TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
    *
};
class Solution {
public:
    bool IsBalanced_Solution(TreeNode* pRoot) {
        return dfs(pRoot) != -1;
    }
    int dfs(TreeNode* root)//返回值不是-1的话，其余的返回值表示的是树高
    {
        if (root == nullptr) return 0;
        int left = dfs(root->left);
        if (left == -1) return -1;
        int right = dfs(root->right);
        if (right == -1) return -1;
        return abs(left - right) <= 1 ? max(left, right) + 1 : -1;
    }
};

//2.最大子矩阵(前缀和)
// #include <iostream>
using namespace std;
const int N = 110;
int n;
int dp[N][N];
int main()
{
    int x;
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= n; j++)
        {
            cin >> x;
            dp[i][j] = dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - 1] + x;
        }
    }
    int ret = -127 * N;
    for (int x1 = 1; x1 <= n; x1++)
    {
        for (int y1 = 1; y1 <= n; y1++)
        {
            for (int x2 = x1; x2 <= n; x2++)
            {
                for (int y2 = y1; y2 <= n; y2++)
                {
                    ret = max(ret, dp[x2][y2] - dp[x1 - 1][y2] - dp[x2][y1 - 1] + dp[x1 - 1][y1 - 1]);
                }
            }
        }
    }
    cout << ret << endl;
    return 0;
}
//3.小葱的01串
#include <iostream>
#include <string>
int n;
string s;
int main()
{
    cin >> n >> s;
    int sum[2] = { 0 }; // 统计字符串中所有 0 和 1 的个数
    for (auto ch : s)
    {
        sum[ch - '0']++;
    }

    int left = 0, right = 0, ret = 0, half = n / 2;
    int count[2] = { 0 }; // 统计窗⼝内 0 和 1 的个数
    while (right < n - 1) // 细节问题
    {
        count[s[right] - '0']++;
        while (right - left + 1 > half)
        {
            count[s[left++] - '0']--;
        }
        if (right - left + 1 == half)
        {
            if (count[0] * 2 == sum[0] && count[1] * 2 == sum[1])
            {
                ret += 2;
            }
        }
        right++;
    }

    cout << ret << endl;

    return 0;
}